//
//  STVisitorViewController.swift
//  STVVeibo
//
//  Created by leergou on 16/7/19.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

import UIKit

class STVisitorViewController: UIViewController {

    // 标记用户是否登录
    var isLogin: Bool = STUserAccountViewModel.sharedUserAccountTools.isLogin
    // 声明属性
    var visitorView: STVisitorView?
    
    override func loadView() {
        super.loadView()
        isLogin ? view = tableView : loadVisitorView()
    }
    
    
    //MARK: 按钮点击监听
    @objc private func loginClick() {
        // modal出一个控制器
        let OAuthoVc = STOAuthViewController()
        presentViewController(UINavigationController(rootViewController: OAuthoVc), animated: true, completion: nil)
    }
    
    //MARK: 设置访客视图
    private func loadVisitorView(){
        // 实例化
        visitorView = STVisitorView()
        visitorView?.closure = {[weak self] in
            
            self?.loginClick()
        }
        
        view = visitorView
        // 设置导航栏
        setupNav()
    }
    
    //MARK: setupNav
    func setupNav() {
        
        // 用分类
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", imgName: nil, target: self, action: "loginClick")
        // 用自定义类
        navigationItem.rightBarButtonItem = STBarButtonItem(title: "注册", imgName: nil, target: self, action: "loginClick")
    }
    
    //MARK: viewDidLoad
    override func viewDidLoad() {
        super.viewDidLoad()

        
        
        
        
    }
    
    //MARK: lazy
    lazy var tableView: UITableView = UITableView()
}
